package com.example.rabbitmq.bugtest1;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @author audy
 * @description: TODO
 * @date 2022/8/7 23:43
 */
@Component
public class RabbitConfig {

    public static final String QUEUE = "newuserQueueCompensation";
    public static final String EXCHANGE = "newuserExchangeCompensation";
    public static final String ROUTING_KEY = "newuserRoutingCompensation";


    @Bean(QUEUE)
    public Queue queue(){
        return new Queue(QUEUE);
    }

    @Bean(EXCHANGE)
    public Exchange exchange(){
        return ExchangeBuilder.directExchange(EXCHANGE).durable(true).build();
    }

    @Bean
    public Binding binding(@Qualifier(QUEUE) Queue queue,
                           @Qualifier(EXCHANGE) Exchange exchange){
       return BindingBuilder.bind(queue).to(exchange).with("newuserRoutingCompensation").noargs();
    }
}
